export function displayDate(str: string): string {
  const now = new Date().getTime()
  const oldTime = new Date(str).getTime()
  const difference = now - oldTime
  const minute = 1000 * 60
  const hour = minute * 60
  const day = hour * 24
  const month = day * 30
  const year = month * 12
  const _year = difference / year
  const _month = difference / month
  const _week = difference / (7 * day)
  const _day = difference / day
  const _hour = difference / hour
  const _min = difference / minute

  let result = ''

  if (_year >= 1) {
    result = '发表于 ' + ~~(_year) + ' 年前'
  } else if (_month >= 1) {
    result = '发表于 ' + ~~(_month) + ' 个月前'
  } else if (_week >= 1) {
    result = '发表于 ' + ~~(_week) + ' 周前'
  } else if (_day >= 1) {
    result = '发表于 ' + ~~(_day) + ' 天前'
  } else if (_hour >= 1) {
    result = '发表于 ' + ~~(_hour) + ' 个小时前'
  } else if (_min >= 1) {
    result = '发表于 ' + ~~(_min) + ' 分钟前'
  } else {
    result = '刚刚'
  }
  return result
}
